home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 119
/
(Vol 119) Nov 09 2010.iso
/
Games
/
orbitrax.swf
/
scripts
/
DefineSprite_1014
/
frame_1
/
DoAction.as
Wrap
Text File
|
2010-11-09
|
7KB
|
267 lines
function addObjIfHit(anObj, hitType, tableType)
{
var i = 1;
while(i <= hitZoneQty)
{
if(anObj.hitTest(eval(hitType + i)))
{
eval(tableType + i).push(anObj);
}
i++;
}
}
function startTimer(thisTimeOut)
{
initTimer = getTimer() / 1000;
clock._visible = true;
bumpSnd.gotoAndPlay("popup");
clock.onEnterFrame = function()
{
timeElaped = Math.abs(getTimer() / 1000) - initTimer;
clock.showTime(timeElaped,thisTimeOut);
if(thisTimeOut - Math.floor(timeElaped) <= 0)
{
clock._visible = false;
main.keyActive = true;
main.energyBar.energyBar.bar._x = main.energyGame;
delete clock.onEnterFrame;
}
};
}
function getName()
{
i++;
return "o" + i;
}
function fadeLine(line)
{
var _loc1_ = line;
_loc1_._alpha -= aDec;
if(_loc1_._alpha <= 0)
{
clearInterval(_loc1_.intervalID);
removeMovieClip(_loc1_);
}
}
function traceLine(objX, objY, gObj, moveTo)
{
var _loc1_ = gObj;
pt = allCar.getPoint(allCar.car.wbl);
objXL = objX + pt.x;
objYL = objY + pt.y;
pt = allCar.getPoint(allCar.car.wbr);
objXR = objX + pt.x;
objYR = objY + pt.y;
lineL.lineStyle(_loc1_.tline,_loc1_.cline,_loc1_.aline);
if(moveTo)
{
lineL.moveTo(objXL,objYL);
}
lineL.lineTo(objXL,objYL);
lineL = map.createEmptyMovieClip("line" + cl,100 + cl++);
lineL.moveTo(objXL,objYL);
lineL.intervalID = setInterval(fadeLine,sfade,lineL);
lineR.lineStyle(_loc1_.tline,_loc1_.cline,_loc1_.aline);
if(moveTo)
{
lineR.moveTo(objXR,objYR);
}
lineR.lineTo(objXR,objYR);
lineR = map.createEmptyMovieClip("line" + cl,100 + cl++);
lineR.moveTo(objXR,objYR);
lineR.intervalID = setInterval(fadeLine,sfade,lineR);
cl %= mline;
}
function checkBorder(obj, line)
{
var _loc1_ = line;
var _loc2_ = obj;
if(_loc1_.tcol)
{
if(_loc2_.hitZone.hitTest(_loc1_))
{
var dx = _loc1_._x - _loc2_._x;
var dy = _loc1_._y - _loc2_._y;
var y1 = _loc1_.cosa * dy - _loc1_.sina * dx;
var _loc3_ = _loc1_.cosa * _loc2_.vy - _loc1_.sina * _loc2_.vx;
if(y1 < 1 && y1 > - _loc3_)
{
var x1 = _loc1_.cosa * dx + _loc1_.sina * dy;
var vx1 = _loc1_.cosa * _loc2_.vx + _loc1_.sina * _loc2_.vy;
y1 = 1;
var vFactor = Math.abs(_loc2_.speed) >= 1 ? Math.abs(_loc2_.speed) : 1;
_loc3_ *= bounce * vFactor;
_loc2_.tspeed = 0;
_loc3_ = _loc3_ <= - _loc2_.trust ? _loc3_ : - _loc2_.trust;
_loc2_.vx = _loc1_.cosa * vx1 - _loc1_.sina * _loc3_;
_loc2_.vy = _loc1_.cosa * _loc3_ + _loc1_.sina * vx1;
dx = _loc1_.cosa * x1 - _loc1_.sina * y1;
dy = _loc1_.cosa * y1 + _loc1_.sina * x1;
return true;
}
}
return false;
}
}
function checkObs(obj1, obj2)
{
var _loc1_ = obj2;
var _loc2_ = obj1;
var dx = _loc1_._x - _loc2_._x;
var _loc3_ = _loc1_._y - _loc2_._y;
var dist = Math.sqrt(dx * dx + _loc3_ * _loc3_);
if(dist < _loc2_.ray + _loc1_.ray)
{
var angle = Math.atan2(_loc3_,dx);
cosa = Math.cos(angle);
sina = Math.sin(angle);
vx1p = cosa * _loc2_.vx + sina * _loc2_.vy;
vy1p = cosa * _loc2_.vy - sina * _loc2_.vx;
if(!_loc1_.lock)
{
vx2p = cosa * _loc1_.vx + sina * _loc1_.vy;
vy2p = cosa * _loc1_.vy - sina * _loc1_.vx;
P = vx1p * _loc2_.m + vx2p * _loc1_.m;
}
else
{
vx2p = (- vx1p) * 2;
vy2p = (- vy1p) * 2;
P = vx1p * _loc2_.m;
}
V = vx1p - vx2p;
vx1p = (P - _loc1_.m * V) / (_loc2_.m + _loc1_.m);
_loc2_.vx = cosa * vx1p - sina * vy1p;
_loc2_.vy = cosa * vy1p + sina * vx1p;
if(!_loc1_.lock)
{
vx2p = V + vx1p;
_loc1_.vx = cosa * vx2p - sina * vy2p;
_loc1_.vy = cosa * vy2p + sina * vx2p;
}
diff = (_loc2_.ray + _loc1_.ray - dist) / 2;
cosd = cosa * diff;
sind = sina * diff;
_loc2_.tspeed = 0;
_loc2_._x -= cosd;
_loc2_._y -= sind;
if(!_loc1_.lock)
{
_loc1_._x += cosd;
_loc1_._y += sind;
_loc1_.mTween();
}
return true;
}
return false;
}
function computeTrack(dotNbr)
{
points = new Array();
numPoints = dotNbr;
mid = new Array();
i = 0;
while(i < numPoints)
{
angle = 6.283185307179586 / numPoints * i;
points[i] = eval("piste.d" + i);
mid[i] = {};
i++;
}
i = 0;
while(i < numPoints - 1)
{
mid[i].x = (points[i]._x + points[i + 1]._x) / 2;
mid[i].y = (points[i]._y + points[i + 1]._y) / 2;
i++;
}
mid[i].x = (points[i]._x + points[0]._x) / 2;
mid[i].y = (points[i]._y + points[0]._y) / 2;
}
function computeTrack2(dotNbr)
{
pointsT = new Array();
numPointsT = dotNbr;
midT = new Array();
i = 0;
while(i < numPointsT)
{
angle = 6.283185307179586 / numPointsT * i;
pointsT[i] = eval("piste.t" + i);
midT[i] = {};
i++;
}
i = 0;
while(i < numPointsT - 1)
{
midT[i].x = (pointsT[i]._x + pointsT[i + 1]._x) / 2;
midT[i].y = (pointsT[i]._y + pointsT[i + 1]._y) / 2;
i++;
}
midT[i].x = (pointsT[i]._x + pointsT[0]._x) / 2;
midT[i].y = (pointsT[i]._y + pointsT[0]._y) / 2;
}
function computeTrack3(dotNbr)
{
pointsS = new Array();
numPointsS = dotNbr;
midS = new Array();
i = 0;
while(i < numPointsS)
{
angle = 6.283185307179586 / numPointsS * i;
pointsS[i] = eval("piste.s" + i);
midS[i] = {};
i++;
}
i = 0;
while(i < numPointsS - 1)
{
midS[i].x = (pointsS[i]._x + pointsS[i + 1]._x) / 2;
midS[i].y = (pointsS[i]._y + pointsS[i + 1]._y) / 2;
i++;
}
midS[i].x = (pointsS[i]._x + pointsS[0]._x) / 2;
midS[i].y = (pointsS[i]._y + pointsS[0]._y) / 2;
}
function randomRacingSound()
{
}
_quality = "LOW";
_global.gameMain = this;
clearInterval(main.robotInt);
main.gameStarted = false;
radVal = 0.017453292519943295;
bounce = -0.2;
cl = 0;
mline = 40;
sfade = 50;
aDec = 10;
type1 = new Object();
type2 = new Object();
tcount = 0;
turn = 0;
carArray = new Array();
hitArray = new Array();
mapArray = new Array();
hitZoneQty = 4;
turnTotal = eval("main.track" + main.pisteNbr + ".turnTotal");
var i = 1;
while(i <= hitZoneQty)
{
set("borderArray" + i,new Array());
set("obsArray" + i,new Array());
set("hitArray" + i,new Array());
set("gArray" + i,new Array());
set("zoneArray" + i,new Object());
zoneArrayTarget = eval("zoneArray" + i);
zoneArrayTarget.borderArray = eval("borderArray" + i);
zoneArrayTarget.obsArray = eval("obsArray" + i);
zoneArrayTarget.hitArray = eval("hitArray" + i);
zoneArrayTarget.gArray = eval("gArray" + i);
i++;
}
upArray = new Array();
main.selectTrack(main.pisteNbr);
gotoAndStop("track" + main.pisteNbr);